//
//  thirdViewController.m
//  tabbarApp
//
//  Created by CPX on 2018/9/30.
//  Copyright © 2018 CPX. All rights reserved.
//

#import "thirdViewController.h"
#import "CDSideHeadView.h"
#import "CDSideCell.h"
#import "CDFeedbackViewController.h"
#import "UIViewController+SideMenu.h"
#import "CDGuide2ViewController.h"
#import "CDFeedbackViewController.h"
#import "CDAgreementViewController.h"
@interface thirdViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) CDSideHeadView *sideHeadView;
@end

@implementation thirdViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self sideHeadView];
    
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.backgroundColor = [UIColor whiteColor];
    _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
    _tableView.tableHeaderView = self.sideHeadView;
    
    [self.tableView registerNib:[UINib nibWithNibName:@"CDSideCell" bundle:nil] forCellReuseIdentifier:@"sideCell"];
}
-(CDSideHeadView *)sideHeadView{
    if (!_sideHeadView) {
        _sideHeadView = [CDSideHeadView szd_initUIView];
        _sideHeadView.frame = CGRectMake(0, 0, kDeviceWidth, 0);
        _sideHeadView.backgroundColor = [UIColor redColor];
    }
    return _sideHeadView;
}
#pragma mark - UITableViewDelegate -

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return 4;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    CDSideCell *cell = [tableView dequeueReusableCellWithIdentifier:@"sideCell"];
    if (indexPath.row == 0) {
        cell.titleLab.text = @"使用教程";
        cell.iconImg.image = [UIImage imageNamed:@"使用教程"];
    }else if (indexPath.row == 1){
        cell.titleLab.text = @"意见反馈";
        cell.iconImg.image = [UIImage imageNamed:@"意见反馈"];
    }else if (indexPath.row == 2){
        cell.titleLab.text = @"用户协议";
        cell.iconImg.image = [UIImage imageNamed:@"用户协议"];
    }else if (indexPath.row == 3){
        cell.titleLab.text = @"隐私政策";
        cell.iconImg.image = [UIImage imageNamed:@"隐私政策"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    
    
    if (indexPath.row == 0) {
        CDGuide2ViewController *vc = [[CDGuide2ViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }else if (indexPath.row == 1){
        CDFeedbackViewController *vc = [[CDFeedbackViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }else if (indexPath.row == 2){
        CDAgreementViewController *vc = [[CDAgreementViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }else if (indexPath.row == 3){
        CDAgreementViewController *vc = [[CDAgreementViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
    !self.hideSideClickBlock?:self.hideSideClickBlock();
    
//    CDFeedbackViewController *vc = [[CDFeedbackViewController alloc]init];
//    [self.navigationController pushViewController:vc animated:YES];

}

@end
